<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;

        }
        ul{
            overflow: hidden;
            margin-left: 500px;
        }
        ul li{
            float: left;
            width: 100px;
            height: 30px;
            margin-right: 10px;
        }
        ul li:nth-of-type(1){
            background:blue;
        }
        section>div{
            margin-left: 400px;
            width: 500px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            display: none;
        }
        section>div:nth-of-type(1){
            display: block;
        }
    </style>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
    <section>
        <div><img src="images/456.jpg" alt=""></div>
        <div><img src="images/567.jpg" alt=""></div>
        <div><img src="images/123.jpg" alt=""></div>
        <div><img src="images/321.jpg" alt=""></div>
    </section>
    <script>
        var tags=document.getElementsByTagName('li');
        var boxs=document.getElementsByTagName('div');
        for(var i=0;i<tags.length;i++){
            tags[i].index=i;
            tags[i].onclick=function(){
                for(var j=0;j<tags.length;j++){
                    tags[j].style.background="none";
                    boxs[j].style.display="none"
                }
                this.style.background='blue';
                var n=this.index;
                boxs[n].style.display='block'
            }
        }
    </script>


    
</body>
</html>